
//初始化
var web = new Vue({
    el : '#body',
    data () {
        return {
            id : $config.GetQueryString('id'),
            first : ''
        }
    },
    created(){
        this.getList();
    },
    mounted(){
        this.setQrcode();
    },
    methods : {
        getList (isload){
            var _this = this;
            //请求数据
            $.ajax({
                url : $config.host()+'/NBASearch/GetInformation',
                dataType : 'json',
                data : {
                    type  : 'GetByPlayerNo',
                    value : _this.id
                },
                success(json){
                    if(json.success && json.player){
                        _this.first = json.player;
                    }
                }
            })
        },
        vote () {
            var _this = this;
            var loading = layer.load(2, {
                shade: [0.2,'#fff'] //0.1透明度的白色背景
            });
            $.ajax({
                type : 'post',
                url : $config.host()+'/NBAVote/DoVote',
                dataType : 'json',
                data : {
                    playerNo  : _this.id
                },
                success(json){
                    if(json.success){
                        _this.first.votetotal++;
                    }
                    _this.common().layer_alert(json.message.fMsg);

                    //去除loading层
                    layer.close(loading);
                }
            })
        },
        setQrcode (){
            var size = $('.qrcode').width(),
                href = location.href;
            $('.qrcode').qrcode({width:  size,height: size,text: href});
        },
        player_video (index) {
            if($config.IsPC()){
                var box;
                $('.video-play-box video').hide();
                $('.video-play-box video').eq(index).show()
                box = layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    area: ['1000px', '600px'],
                    skin: 'layui-layer-nobg', //没有背景色
                    shadeClose: true,
                    content: $('.video-play-box')
                });
                document.querySelectorAll('.video-play-box video')[index].play()
            }else{
                $('.video-play-box').show();
                document.querySelectorAll('.video-play-box video')[index].play()
            }
        }
    }
})